package com.viroyal.monitorlib.entity.rx;

import android.content.Context;

import com.google.gson.Gson;
import com.viroyal.monitorlib.network.Api;

/**
 * Created by zy on 2017/11/17.
 */

public class UpdateRes {
    public String dev_sn;
    public String action;
    //    id	本次事件的id
    //    pkg_name	应用包名	string
    //    status	完成标记	number	1-安装成功 2-其他原因安装失败 3-无法自动安装需要手动介入 4-版本已存在, 5-下载失败

    public long id;
    public int status;
    public Integer download_progress;

    public UpdateRes(long id, String action, Context context) {
        this.id = id;
        this.action = action;
        dev_sn = Api.get().getDeviceId(context);
    }

    public UpdateRes alreadyInstall() {
        status = 4;
        return this;
    }

    public UpdateRes noAuto() {
        status = 3;
        return this;
    }

    @Override
    public String toString() {
        return new Gson().toJson(this);
    }
}
